package com.jiang.daily.Q3228;

/**
 * @author Jiang
 * @version 1.0
 * @date 2025/11/13 09:40
 */
class Solution {
    public int maxOperations(String s) {
        int cnt = 0;
        boolean flag = false;
        int res = 0;

        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '1') {
                cnt++;
                flag = true;
            } else if (flag) {
                res += cnt;
                flag = false;
            }
        }
        return res;
    }
}
